<?php 
if(!isset($_SESSION))
{
session_start();
}
/*
  @Get Theme informations and save them to PHP Constants
  @Author : VTHANH_88 from themecenter.net
*/
//set the contrain 
define('THEME_NAME','Matchbox');
define('THEME_DIR',get_template_directory());
define('THEME_URI',get_template_directory_uri());
define('THEME_SLUG','TT');
define('THEME_VERSION',"1.0.0");
//LANG
//set the folder contrain
//API
define('API_DIR',THEME_DIR.'/apis');
define('API_URI',THEME_URI.'/apis');
//include
define('INCLUDE_DIR',THEME_DIR.'/include');
define('INCLUDE_URI',THEME_URI.'/include');
// Theme Langguage
define('LANG',THEME_DIR.'/lang');
load_theme_textdomain( 'TT', LANG);

define('CSS_URI',THEME_URI.'/css');
define('JS_URI',THEME_URI.'/js');
define('IMAGE_URI',THEME_URI.'/images');
define('THEME_PART_DIR',THEME_DIR.'/theme_part');

//Load API
require_once(API_DIR.'/api.php');
//LOAD THEME PART
require_once(THEME_PART_DIR.'/include_theme_part.php');
/* Load Skin Dir*/
$skin ='';
if(get_theme_option('general','enable_using_skin_file') == 'true' && get_theme_option('general','enable_demo_link')<> 'true'):
$skin = get_theme_option('general','skin_selected');
elseif(get_theme_option('general','enable_using_skin_file') <> 'true' && get_theme_option('general','enable_demo_link')<> 'true'):
$skin = get_theme_option('style','style_skin_selected');
elseif(get_theme_option('general','enable_demo_link')=='true'):
		if(isset($_GET["skin"])){$_SESSION["skin"] = $_GET["skin"];};
		if(isset($_SESSION["skin"])):
		$skin =$_SESSION["skin"];
		endif;
		
endif;
define('SKIN_URI',THEME_URI.'/images/color/'.$skin);
add_theme_support('automatic-feed-links');
function oreva_type_link_filter_function( $post_link, $id = 0, $leavename = FALSE ) {
    if ( strpos('%portfolio-types%', $post_link) === 'FALSE' ) {
      return $post_link;
    }
    $post = get_post($id);
    if ( !is_object($post) || $post->post_type != 'portfolio' ) {
      return $post_link;
    }
    $terms = wp_get_object_terms($post->ID, 'portfolio-types');
    if ( !$terms ) {
      return str_replace('%portfolio-types%/', '', $post_link);
    }
    return str_replace('%portfolio-types%', $terms[0]->slug, $post_link);
  }
add_filter('post_type_link', 'oreva_type_link_filter_function', 1, 3);

/**
 * Set the content width based on the theme's design and stylesheet.
 *
 * Used to set the width of images and content. Should be equal to the width the theme
 * is designed for, generally via the style.css stylesheet.
 */
if ( ! isset( $content_width ) )
	$content_width = 900;

?>